﻿

using Sorting.App.Models.Enum;

namespace Moreeasi.TaskQueue
{
    /// <summary>
    /// 单元任务
    /// </summary>
    public abstract class UnitTask
    {
        /// <summary>
        /// 任务Id
        /// </summary>
        public string? TaskId { get; set; }



        /// <summary>
        /// 任务序号
        /// </summary>
        public int? TaskSeq { get; set; }



        /// <summary>
        /// 子任务
        /// </summary>
        public string? TaskSubId { get; set; }

        /// <summary>
        /// 任务类型
        /// </summary>
        public string? TaskType { get; set; }
        /// <summary>
        /// 任务名称
        /// </summary>
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 任务数据
        /// </summary>
        public dynamic Data { get; set; }

        /// <summary>
        /// 任务状态
        /// </summary>
        public EnumTaskState State { get; set; }


        /// <summary>
        /// 错误信息
        /// </summary>
        public string ErrorMsg { get; set; }


        // /// <summary>
        // /// 构造函数
        // /// </summary>
        // /// <param name="name"></param>
        // protected  UnitTask  _unitTask { get; set; }

        public override string ToString() => $"任务：{this.Name}";


        /// <summary>
        /// 执行任务
        /// </summary>
        public abstract void ExecuteNew();

    }
}
